import { ref, computed } from "vue";
import { defineStore } from "pinia";

export const useCounterStore = defineStore(
  "counter",
  () => {
    interface count1Type {
      name: number,
      value: string,
      key: string
  }
  
    const count = ref(0);

    const count1 = ref<count1Type>({name:0,value:'',key:''});
    count1.value = {name:333,value:'ahdgajh',key:'155544'}
    const doubleCount = computed(() => count.value * 2);
    function increment() {
      console.log(count1.value.name)
      count1.value.name = ++count1.value.name
      setTimeout(() => {
        count.value++;
      
      }, 1000);
    }

    return { count,count1, doubleCount, increment };
  },
  {
    persist: true,
  }
);
